package com.chixing.day16.IODemo;

import java.io.*;

/**
 * 适用于文本形式
 * 带有缓冲区的字符流
 * char :8192字符
 * charBufferSize :8192
 */
public class BufferedWriterDemo {
    public static void main(String[] args) {
        BufferedWriter bw = null;
        try {
            //封装 外层字符流 -> 将字节流转换成字符流(转换流) -> 字节写入流
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("//Users//jasonmarslyon//CX_Workspace//Java_Workspace//Test//t.txt")), 1024);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        //写入
        try {
            bw.write("hello ! test,test");
            bw.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally { //关闭
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
}
